package com.strato.queue.v1_0_0.api;

import com.strato.batch.base.v1_0_0.api.Job;
import com.strato.batch.base.v1_0_0.api.JobConsumer;
import com.strato.batch.base.v1_0_0.api.JobExecutionConfig;
import com.strato.queue.v1_0_0.jdbc.model.QueueMessage;


public abstract class QueueConsumer implements JobConsumer<QueueMessage>{

	@Override
	public final void consume(Job<QueueMessage> job, JobExecutionConfig<QueueMessage> config) {
		if(job==null){
			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}else{
			doConsume(job,config);
		}
	}

	protected abstract void doConsume(Job<QueueMessage> job, JobExecutionConfig<QueueMessage> config);
	
}
